package com.ruix.app.mapper;

import com.ruix.app.model.UncomfirmedUser;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by hadexs on 2017/4/24.
 */

public class UncomfirmedUserMapper implements ApiMapper<ArrayList<UncomfirmedUser>> {


    @Override
    public ArrayList<UncomfirmedUser> transform(JSONObject response) {
        ArrayList users = new ArrayList();
        JSONObject data = response.optJSONObject("data");
        if (data != null) {
            JSONArray postList = data.optJSONArray("unconfirmed_list");
            if (postList != null) {
                for (int i = 0; i < postList.length(); i++) {
                    JSONObject object = postList.optJSONObject(i);
                    UncomfirmedUser user = new UncomfirmedUser().parse(object);
                    users.add(user);
                }
            }
        }
        return users;
    }
}